﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using LojaVirtual.Infra.Mapeamentos;
using System.Data.Entity.Infrastructure;
using LojaVirtual.Comuns.Produtos;
using LojaVirtual.Comuns.Clientes;
using System.Data.Objects;

namespace LojaVirtual.Infra
{
    public class LojaVirtualContext : DbContext
    {
		public DbSet<Categoria> Categorias { get; set; }
		public DbSet<Produto> Produtos { get; set; }
		public DbSet<Cliente> Clientes { get; set; }
		public DbSet<Compra> Compras { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
			modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
			modelBuilder.Conventions.Remove<IncludeMetadataConvention>();


			modelBuilder.Configurations.Add(new CategoriaConfiguration());
			modelBuilder.Configurations.Add(new ProdutoConfiguration());

			modelBuilder.Configurations.Add(new ClienteConfiguration());
			modelBuilder.Configurations.Add(new CompraConfiguration());
			modelBuilder.Configurations.Add(new ItemCompraConfiguration());
			
        }
    }
}
